import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

/**
 * 需求: 模拟双色球系统
 * 死循环+信号位 解决红色球不重复
 */
public class DoubleColorBall {
    public static void main(String[] args) {
        int[] prizeNumber = prizeNumber();
        int[] userNumber = userNumber();
        //2. 用户输入自己的数组
        //3. 比较prizeNumber 和 userNumber
        compare(prizeNumber,userNumber);
    }
    public static int[] prizeNumber(){
        //1. 随机生成一组中将号码 6个红色号码球 + 1个蓝色号码球 红色号码球从1-33中出来，蓝色从1-16中出来
        // 重点是红球号码不能重复，蓝色号码可以
        int[] prizeNumber = new int[7];
        Random random = new Random();
        for (int i = 0; i < 7; i++) {
            if (i<6){
                while(true){
                    int red = random.nextInt(33) + 1;
                    boolean flag = true;
                    for (int j = 0; j < i; j++) {
                        if(prizeNumber[j] == red){
                            flag = false;
                            break;
                        }
                    }
                    if(flag){
                        prizeNumber[i]=red;
                        break;
                    }
                }
            } else {
                int blue = random.nextInt(16) + 1;
                prizeNumber[i]=blue;
            }
        }
        System.out.println("本期中将号码:"+Arrays.toString(prizeNumber));
        return  prizeNumber;
    }
    public static int[] userNumber(){
        int[] userNumber = new int[7];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < userNumber.length-1; i++) {
            System.out.println("输入红色球号码:1-33");
            userNumber[i]=sc.nextInt();
        }
        System.out.println("输入蓝色球号码:1-16");
        userNumber[6]=sc.nextInt();
        System.out.println("你选择的号码为:"+Arrays.toString(userNumber));
        sc.close();
        return userNumber;
    }
    public static void compare(int[] prizeNumber, int[] userNumber){
        int redCount = 0;
        int blueCount = 0;
        for (int i = 0; i < prizeNumber.length-1; i++) {
            for (int j = 0; j < userNumber.length-1; j++) {
                if(prizeNumber[i]==userNumber[j]){
                    redCount++;
                    break;
                }
            }
        }
        if(prizeNumber[6] == userNumber[6]){
            blueCount++;
        }
        switch (redCount){
            case 6:
                switch (blueCount){
                    case 0:
                        System.out.println("中500w");
                        break;
                    case 1:
                        System.out.println("中1000w");
                        break;
                }
                break;
            case 5:
                switch (blueCount){
                    case 0:
                        System.out.println("中200");
                        break;
                    case 1:
                        System.out.println("中3000");
                        break;
                }
                break;
            case 4:
                switch (blueCount){
                    case 0:
                        System.out.println("中10");
                        break;
                    case 1:
                        System.out.println("中200");
                        break;
                }
                break;
            case 3:
                switch (blueCount){
                    case 0:
                        System.out.println("没有中奖");
                        break;
                    case 1:
                        System.out.println("中10");
                        break;
                }
                break;
            case 2:
                switch (blueCount){
                    case 0:
                        System.out.println("没有中奖");
                        break;
                    case 1:
                        System.out.println("中5元");
                        break;
                }
                break;
            case 1:
                switch (blueCount){
                    case 0:
                        System.out.println("没有中奖");
                        break;
                    case 1:
                        System.out.println("中5");
                        break;
                }
                break;
            case 0:
                switch (blueCount){
                    case 0:
                        System.out.println("没有中奖");
                        break;
                    case 1:
                        System.out.println("中5");
                        break;
                }
                break;
            default:
                System.out.println("没有对应奖项");
        }
    }
}
